<template>
	<view class="content">
		<z-paging ref="paging" v-model="data.dataList" @query="queryList">
			<template #top>
				<view class="search-box" style="">
				</view>
			</template>
			<view class="contract-list flex" @click="itemClick(item)" v-for="(item,index) in data.dataList"
				:key="index">
				<image class="file-icon" :src="item.member_seal_images_url" style="width: 100rpx; height: 100%;">
				</image>
				<view class="title_box">
					<text class="title">{{ item.member_seal_title }}</text>
				</view>
				<view class="use"> 使用 </view>
			</view>
			<template #loadingMoreNoMore>
				<custom-nomore></custom-nomore>
			</template>
		</z-paging>
		<key-board ref="keyboardC" @return-pass="returnPass"></key-board>
	</view>
</template>
<script setup>
	import KeyBoard from "../../../components/keyboard.vue";
	import {
		sealList
	} from "@/api/module/mine";
	import {
		onLoad
	} from "@dcloudio/uni-app";
	import {
		ref,
		reactive
	} from 'vue';
	import {
		useStore
	} from 'vuex';
	import {
		userContractSign,
		keySign,
		fileSignStore,
	} from "../../../api/module/contract";
	import {
		goNav
	} from "../../../utils/common";
	import {
		authentication,
		jump
	} from "../../../utils/contract/isAuthentication.js"
	const data = reactive({
		dataList: [],
		member_contract_id: 0,
		member_seal_id: 0,
		keyword: '',
		file_id: '',
	})
	const store = useStore()
	const paging = ref(null)
	const queryList = (pageNo, pageSize) => {
		sealList({
			page: pageNo,
			limit: pageSize,
		}).then(res => {
			paging.value.complete(res.data)
		});
	}
	const clear = () => {
		paging.value.reload();
	}
	const search = () => {
		paging.value.reload();
	}
	const annex_file = ref([]);
	const keyboardC = ref();
	onLoad((options) => {
		console.log(options)
		data.signer_type = options.signer_type;
		data.keyword = options.keyword;
		data.file_id = options.file_id;
		data.member_contract_id = options.member_contract_id;
		if (typeof(options.annex_file) == 'string') {
			annex_file.value = options.annex_file.split(',')
		}
	})
	const itemClick = (item) => {
		data.member_seal_id = item.member_seal_id;
		let params = {
			member_contract_id: data.member_contract_id,
			member_seal_id: data.member_seal_id,
			member_seal_image: '',
			annex_file: annex_file.value,
			signer_type: data.signer_type,
		}
		keyboardC.value.open(params)
		// uni.showModal({
		//   title: '签署密码',
		//   content: '',
		//   editable: true, //是否显示输入框
		//   placeholderText: '请输入签署密码', //输入框提示内容
		//   confirmText: '确认',
		//   cancelText: '取消',
		//   success: (res) => {
		//     if (res.confirm) {
		//       let params = {
		//         member_contract_id: data.member_contract_id,
		//         member_seal_id: data.member_seal_id,
		//         member_seal_image: '',
		//         password: res.content,
		//         annex_file: annex_file.value,
		//         signer_type: data.signer_type,
		//       }
		//       userContractSign(params).then(result => {
		//         if (res.status_code == 501) {
		//           jump(store.state.userType)
		//         }
		//         goNav(`/pages/contract/enterprise/detail?member_contract_id=${data.member_contract_id}`)
		//       })
		//     }
		//   }
		// })
	}
	const returnPass = (ref) => {
		const form = {
			file_id: data.file_id,
			member_seal_id: ref.member_seal_id,
			member_seal_image: ref.member_seal_image,
			password: ref.password,
			key_word: data.keyword
		}
		fileSignStore(form).then(result => {
			if (result.status_code == 501) {
				jump(store.state.userType)
			}
			uni.redirectTo({
				url: '/pages/contract/file-list'
			});
			// goNav(`/pages/contract/enterprise/detail?member_contract_id=${data.member_contract_id}`)
		})
		// keySign(data).then(result => {
		// 	if (result.status_code == 501) {
		// 		jump(store.state.userType)
		// 	}
		// 	goNav(`/pages/contract/enterprise/detail?member_contract_id=${data.member_contract_id}`)
		// })
	}
</script>
<style lang="scss" scoped>
	.search-box {
		padding: 16rpx 32rpx;
		box-sizing: border-box;
		height: 100rpx;
	}

	.contract-list {
		border-bottom: 2rpx solid #E7E7E7;
		height: 110rpx;
		align-items: center;
		padding: 0 32rpx;

		.file-icon {
			width: 33rpx;
			height: 42rpx;
		}

		.title_box {
			flex: 1;
			margin: 0 16rpx;

			.title {
				width: 368rpx;
				font-size: 32rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.9);
				display: -webkit-box;
				/* WebKit浏览器支持 */
				overflow: hidden;
				/* 隐藏超出部分 */
				text-overflow: ellipsis;
				/* 显示省略号 */
				white-space: nowrap;
			}
		}

		.use {
			font-size: 32rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			color: #4787F0;
		}
	}
</style>